package com.pj.wisdomlogistics.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.pj.wisdomlogistics.R;
import com.pj.wisdomlogistics.entity.TakeoutDetailInfo;
import com.pj.wisdomlogistics.ui.view.recyclerview.BaseAdapter;
import com.pj.wisdomlogistics.ui.view.recyclerview.BaseViewHolder;
import com.zhy.autolayout.utils.AutoUtils;

/**
 * Created by HelloWorld on 2017/9/13.
 */

public class TakeoutDetailAdapter extends BaseAdapter<TakeoutDetailInfo.DetailListBean , BaseViewHolder> {
    public TakeoutDetailAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder createCustomViewHolder(ViewGroup parent, int viewType) {
        return new BaseViewHolder(parent , R.layout.item_takeout_detail);
    }

    @Override
    public void bindCustomViewHolder(BaseViewHolder viewHolder, int position) {
        AutoUtils.autoSize(viewHolder.itemView);

        final TakeoutDetailInfo.DetailListBean item = getItem(position);
        viewHolder.getTextView(R.id.tv_name).setText(item.getFoodName());
        viewHolder.getTextView(R.id.tv_count).setText("x" + item.getFoodCount());
        viewHolder.getTextView(R.id.tv_total_price).setText("￥" + item.getFoodPrice());
        if(position == getItemCount() - 1){
            viewHolder.getView(R.id.v_dash).setVisibility(View.GONE);
        }
    }

    @Override
    public int getCustomViewType(int position) {
        return 0;
    }
}
